#include <bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
/*
input:n=9, k=5
9 5
10 -5 6 8 9 -10 50 7 -10
output:
*/
int main()
{
    freopen("file.in","r",stdin);
    int n, k, res, sum = 0, tmp;
    int memo[MAX_SIZE];
    cin >> n >> k;
    vector<int> coins;

    for (int i = 0; i < n; i++)
    {
        cin >> res;
        sum += res;
        coins.push_back(res);
    }
    // 求连续n-k个和最小的值
    // 用前缀和
    memo[0] = 0;
    res = INT_MAX;
    for (int i = 1; i <= n; i++)
        memo[i] = memo[i - 1] + coins[i - 1];

    // 取出连续n-k和最小值
    for (int i = 0; i <= k; i++)
    {
        tmp = memo[i + n - k] - memo[i];
        res = min(tmp, res);
    }
    // 减掉最小就是最大值了
    res = sum - res;
    cout << res << endl;
    return 0;
}
/*
作者：张聪明
链接：https://leetcode-cn.com/circle/discuss/J25rYQ/view/8tZPnC/
来源：力扣（LeetCode）
著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
*/